package com.hzqy.service.epg;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.epg.MovieAndSerialDao;
import com.hzqy.web.vo.activity.ActivityVoteUserVo;

@Service
public class MovieAndSerialServiceBean {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private MovieAndSerialDao masDao;

	
	/**
	 * 查询用户投票总数及排序
	 * @param avu
	 * @return
	 */
	public Map<String, Object> selectSisterVotenum (ActivityVoteUserVo acvote,int page, int rows) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("f_avu_activityid", "45");
		map.put("f_awl_activityid", "45");
		map.put("f_awl_prizeid", "001");
		map.put("f_avu_serverid", acvote.getF_avu_serverid());
		map.put("sumvote", acvote.getSumvote());
		map.put("maxdate", acvote.getMaxdate());
		int rowCount = masDao.selectSisterVotenumCount(map);
		map.put("total", rowCount);
		if(rowCount > 0 && page > 0 && rows > 0) {
			map.put("firstResult", (page-1)*rows);
			map.put("maxResults", rows);
			List<ActivityVoteUserVo> results =masDao.selectSisterVotenum(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<ActivityVoteUserVo>());
		}
		return map;
	}
	

	/**
	 * 查询导出
	 * @param avu
	 * @return
	 */
	public Map<String, Object> selectSisterVotenumExcel (ActivityVoteUserVo acvote) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("f_avu_activityid", "45");
		map.put("f_awl_activityid", "45");
		map.put("f_awl_prizeid", "001");
		map.put("f_avu_serverid", acvote.getF_avu_serverid());
		map.put("sumvote", acvote.getSumvote());
		map.put("maxdate", acvote.getMaxdate());
		int rowCount = masDao.selectSisterVotenumCount(map);
		map.put("total", rowCount);
		if(rowCount > 0 ) {
			map.put("firstResult", 0);
			map.put("maxResults", 100000);
			List<ActivityVoteUserVo> results =masDao.selectSisterVotenum(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<ActivityVoteUserVo>());
		}
		return map;
	}

}
